﻿namespace SimpleWebServices.Web.Mvc
{
    using System;
    using System.Net;
    using System.Web;
    using System.Web.Mvc;
    using SimpleWebServices.Net.Mail;

    public sealed class NotFoundResult : ActionResult
    {
        public override void ExecuteResult(ControllerContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException("context");
            }

            HttpResponseBase response = context.HttpContext.Response;

            response.StatusCode = (int)HttpStatusCode.NotFound;
            response.Cache.SetCacheability(HttpCacheability.Public);
            response.Cache.SetExpires(DateTimeFactory.UtcNow.AddHours(1));

            new NotFoundMailMessage(context).Send();
        }
    }
}